package java_thinking.unit_16;

import java.util.Arrays;
import java.util.Random;

/**
 * @Desc:   矩阵数组
 * @author: cww
 * @DateTime: 2019-04-08 21:45
 */

public class _4_1_RaggedArray {
    public static void main(String[] args) {
        Random random = new Random(47);
        int[][][] a = new int[random.nextInt(7)][][];
        for (int i =0;i<a.length;i++) {
            a[i] = new int[random.nextInt(5)][];
            for (int j= 0;j<a[i].length;j++) {
                a[i][j] = new int[random.nextInt(5)];
            }
        }
        System.out.println(a.length);
        System.out.println(Arrays.deepToString(a));
        int[] i1 = new int[10];
        System.out.println("i[] length "+ i1.length);
        //元素个数=length-1
        //! System.out.println("i[10] element "+ i[10]);
        System.out.println("i[9] element "+ i1[9]);
        BerylliumSphere[][] spheres = {
                {new BerylliumSphere(),new BerylliumSphere()},
                {new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere()},
                {new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),
                new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere()},
                {new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),
                new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere(),new BerylliumSphere()},

        };
        //length表示数组有几行
        System.out.println(spheres.length);
        System.out.println("spheres[1][2] :"+spheres[1][2]);
        System.out.println("spheres "+Arrays.deepToString(spheres));

        System.out.println("**********************");
        Integer[][] ai ;
        ai = new Integer[3][];
        System.out.println(ai.length);
        for (int i = 0;i<ai.length;i++) {
            ai[i] = new Integer[3];
            for (int j = 0;j< ai[i].length;j++) {
                ai[i][j] = i * j;
            }
        }
        System.out.println(Arrays.deepToString(ai));

    }
}
